package com.neusoft.controller;

import com.neusoft.service.DrugInfoDtoService;
import com.neusoft.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author akemihomurasama
 */
@RestController
@RequestMapping("/DrugInfoDto")
@CrossOrigin
public class DrugInfoDtoController {
    @Autowired
    private DrugInfoDtoService drugInfoDtoService;

    /**
     * 根据患者id和处方状态查询药品信息和处方id
     *
     * @param registerId 患者id
     * @param drugState  处方状态
     * @return 药品信息
     */
    @RequestMapping("/queryDrugWithPrescriptionId/{registerId}/{drugState}")
    public Result queryDrugWithPrescriptionId(@PathVariable("registerId") int registerId,
                                              @PathVariable("drugState") String drugState) {
        return drugInfoDtoService.queryDrugWithPrescriptionId(registerId, drugState);
    }

    /**
     * 根据患者id查询药品信息并携带处方状态
     *
     * @param registerId 患者id
     * @return 查询结果
     */
    @RequestMapping("/queryDrugWithState/{registerId}")
    public Result queryDrugWithState(@PathVariable("registerId") int registerId) {
        return drugInfoDtoService.queryDrugWithState(registerId);

    }
}
